package deibay.client.gui;

import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import deibay.client.core.views.IPanelBidder;
import deibay.client.core.views.IPanelMain;
import deibay.client.core.views.IPanelSeller;



public class PanelMainView extends JTabbedPane implements IPanelMain{
		
	private PanelBidderView bidderView = null;
	private PanelSellerView sellerView = null;
	private String role;
	
	public PanelMainView()
	{
		super();
		initialize();
	}
	
	private void initialize() {		
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		} 							
		bidderView = new PanelBidderView();
		insertTab("Bidder", null, bidderView, "Bidder View", 0);
		sellerView = new PanelSellerView();
		insertTab("Seller", null, sellerView, "Seller View", 1);
	}

	public IPanelBidder showBidderView() {		
		return bidderView;		
	}

	public IPanelSeller showSellerView() {
		
		return sellerView;
	}

	public void setRole(String role) {
		this.role =role;	
		if(role.equals("bidder"))
			sellerView.setEnabled(false);					
	}

	public void setSelectedTabChangesAction(ChangeListener listener) {
		this.addChangeListener(listener);	
	}

}
